using System.Collections.Generic;
using Framework.Timer;
using Framework.UI;
using GameSystem;
using IcecreamView;

namespace View
{
    public class ViewContinuePanel : IC_AbstractModule
    {

        private int _nextCount;
        public override void OnOpenView(Dictionary<string, IC_ViewData> parameters)
        {
            
            if (GameManager.Instance.GameRoom.NowLevel < 19)
            {
                this._nextCount = GameManager.Instance.GameRoom.NowLevel + 1;
            }
            else
            {
                this._nextCount = 1;
            }
        }
        
        
        [BindUIButton("Continue")]
        private void OnClick_Continue()
        {
            GameManager.Instance.GameRoom.ClearScene();
            GameUpdateMgr.Instance.CreateTimer(1f,
                                               () =>
                                               {
                                                   GameManager.Instance.GameRoom.SetLevel(this._nextCount);
                                                   GameManager.Instance.GameFsm.ChangeState(GameEnum.Game);
                                               });
            
        }

        [BindUIButton("Home")]
        private void OnClick_ToHome()
        {
            GameManager.Instance.GameFsm.ChangeState(GameEnum.Loading , GameEnum.Home);
        }

    }
}